package com.adv.ems.controller.client;

import com.adv.ems.constants.SystemConst;
import com.adv.ems.model.dto.APIRequest;
import com.adv.ems.model.dto.APIResponse;
import com.adv.ems.model.param.LoginParam;
import com.adv.ems.model.vo.LoginVO;
import com.adv.ems.service.UserLoginService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/ems/client")
public class UserLoginController {

    @Resource
    UserLoginService userLoginService;


    @PostMapping("login")
    public APIResponse<LoginVO> login(@RequestHeader(name = SystemConst.Header.ACCEPT_LANGUAGE, defaultValue = SystemConst.Header.ZH_CN) String acceptLanguage,
                                      @Validated @RequestBody APIRequest<LoginParam> request) {
        return APIResponse.<LoginVO>build().content(userLoginService.login(request.getContent(), acceptLanguage));
    }
}
